package com.pb.springbootdemo.service;

import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Destination;
import javax.jms.Queue;


@Service("producer")
public class Producer {

    @Autowired
    private JmsMessagingTemplate jmsTemplate;

    public void sendMsg(String destinationName ,String message){
        System.out.println("------------ 发送消息"+ message);
        Queue queue = new ActiveMQQueue(destinationName);
        jmsTemplate.convertAndSend(queue,message);
    }
}
